/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __ODBC_IMPL_ERR_INFO_H__
#define __ODBC_IMPL_ERR_INFO_H__

#include "include_odbc.h"

////////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_odbc
{

    class err_info
    {
    public:
		err_info();
        ~err_info();

    public:
		const char * get_info( char * lpszInfo, int nSize, int * lpnInfoLen, int * lpnLenNeeded );
		int get_info( SQLSMALLINT handle_type, SQLHANDLE handle );
        // 
        //  0 : success
        //  1 : pending
        //  2 : no data
        // -1 : failed
        // 
        int connect_ret( SQLHANDLE handle, SQLRETURN sqlRet );
        int stmt_ret( SQLHANDLE handle, SQLRETURN sqlRet );
        int env_ret( SQLHANDLE handle, SQLRETURN sqlRet );
		int clear();

	private:
        // 
        //  0 : success
        //  1 : pending
        //  2 : no data
        // -1 : failed
        // 
        int helper_ret( SQLSMALLINT handle_type, SQLHANDLE handle, SQLRETURN sqlRet );
		
	protected:
		std::string m_str_info;

    };

} // xos_odbc

#endif // __ODBC_IMPL_ERR_INFO_H__
